import javax.media.opengl.glu.GLU;
import javax.media.opengl.glu.GLUquadric;


/**
 * Extends genericGlObject with Cylinder.
 *       Created 27/apr/2013.
 * @author Pietro Bolognesi matr. 227383
 * @author Giorgio Lazzaretti matr. 220232
 *  
 */
public class GlCylinder extends GenericGlObject {
	
	/**
	 * Cylinder base width.
	 */
	protected double base = 1.0; 
	/**
	 * Cylinder top width.
	 */
	protected double top = 1.0;
	/**
	 * Cylinder height.
	 */
	protected double height = 1.0;
	/**
	 * Number of slices default 32.
	 * 	 */
	protected int slices = 32;
	/**
	 * Number of slices default 16.
	 */
	protected int stacks = 16;
	
	/**
	 *
	 * @return Width of the base of the cylinder.
	 */
	public double GetBase(){return this.base;}
	/**
	 *
	 * @return Width of the top of the cylinder.
	 */
	public double GetTop(){return this.top;}
	/**
	 *
	 * @return Height of the cylinder.
	 */
	public double GetHeight(){return this.height;}
	/**
	 *
	 * @return Number of slices.
	 */
	public int GetSlices(){return this.slices;}
	/**
	 *
	 * @return Number of stacks.
	 */
	public int GetStacks(){return this.stacks;}
	
	/**
	 * Set the cylinder base width.
	 * @param b Base width.
	 */
	public void SetBase( double b){ this.base = b;}
	/**
	 * Set the cylinder top width.
	 *
	 * @param t Top width.
	 */
	public void SetTop( double t){ this.top = t;}
	/**
	 * Set the cylinder height.
	 *
	 * @param h Height.
	 */
	public void SetHeight( double h){ this.height = h;}
	/**
	 * Set the number of slices.
	 *
	 * @param s Slices.
	 */
	public void SetSlices( int s){ this.slices = s;}
	/**
	 * Set the number of stacks.
	 *
	 * @param s Stacks.
	 */
	public void SetStacks( int s){ this.stacks = s;}
	
	
	
	/**
	 * Create a new cylinder and assign a neutral color.
	 *
	 */
	public GlCylinder(){
		this.Red = 1.0f;
		this.Green = 1.0f;
		this.Blue = 1.0f;
		
		
		this.type = OBJType.CYLINDER;
		this.ObjectName = "Cylinder";
	}

	/**
	 * Draw the cylinder.
	 *
	 */
	@Override
	public void DrawObject(){
		if(!this.ToDraw)
			return;
		GLU glu = new GLU();
		GLUquadric quadric = glu.gluNewQuadric();
		glu.gluCylinder(quadric, this.base, this.top, this.height, this.slices, this.stacks); // Disegno del cilindro
	}

}